package com.bxkc.generator.controller;

import com.bxkc.generator.dto.GeneratorDTO;
import com.bxkc.generator.response.CommonResult;
import com.bxkc.generator.service.GeneratoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhanxiumei
 */
@RestController
@RequestMapping("generator")
public class GeneratorController {

    @Autowired
    private GeneratoService generatoService;

    /**
     * 执行构建的入口
     *
     * @param dto
     *
     * @return
     */
    @RequestMapping("build")
    public CommonResult build(@RequestBody GeneratorDTO dto) {
        return generatoService.build( dto,false );
    }

    /**
     * 构建指定数据库中的全部表
     *
     * @param dto
     *
     * @return
     */
    @RequestMapping("buildAll")
    public CommonResult buildAll(@RequestBody GeneratorDTO dto) {
        return generatoService.buildAll( dto );
    }

    /**
     * 构建指定的表
     * @param dto
     * @return
     */
    @RequestMapping("buildSpecifyTableNames")
    public CommonResult buildSpecifyTableNames(@RequestBody GeneratorDTO dto) {
        generatoService.buildSpecifyTableNames( dto );
        return CommonResult.success();
    }

}
